package com.example.secondhandspringboot.controller;


import com.example.secondhandspringboot.domain.entity.Quality;
import com.example.secondhandspringboot.results.Result;
import com.example.secondhandspringboot.service.IQualityService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 周在林
 * @since 2024-04-02
 */
@RestController
@RequestMapping("/quality")
@CrossOrigin
@Slf4j
@RequiredArgsConstructor
public class QualityController {
    private final IQualityService qualityService;

    /**
     * 获取所有成色
     * @return
     */
    @GetMapping("getQuality")
    @Cacheable(cacheNames = "qualityCache")
    public Result<List<Quality>> getQuality(){
        log.info("获取所有成色");
        List<Quality> qualityList = qualityService.list();
        return Result.success(qualityList);
    }
}
